package com.itheima.stringapi;

public class StringApiDemo {

    public static void main(String[] args) {
        // 字符串对象4种常见的创建方式
        String s1 = "hello";
        System.out.println(s1);
        System.out.println("---------------------------");

        String s2 = new String("hello");
        System.out.println(s2);
        System.out.println("---------------------------");

        char[] chars = {'h','e','l','l','o'};
        String s3 = new String(chars);
        System.out.println(s3);
        System.out.println("---------------------------");

        byte[] bytes = {97,98,99,100,101};
        String s4 = new String(bytes);
        System.out.println(s4);
        System.out.println("---------------------------");

        String s5 = "hello";
        System.out.println(s5 == s1);
        System.out.println(s5 == s2);

        System.out.println("---------------------------");
        System.out.println(s1.equals(s2));

        System.out.println("---------------------------");
        String s6 = "18663656520";
        System.out.println(s6.substring(0,3) + "-" + s6.substring(3,7) + "-" + s6.substring(7));

        System.out.println("---------------------------");

    }
}
